package com.nulldev.util.JVM.reflections.cache;

import java.lang.reflect.Method;
import java.lang.reflect.Modifier;

final class MethodElement {
	protected MethodElement next;
	protected Method method;
	protected Class<?>[] params;
	protected boolean[] primitives;
	protected int paramsLength;
	protected boolean isStatic;

	protected MethodElement(Method method) {
		boolean[] pms = null;
		Class<?>[] args = method.getParameterTypes();
		int len = (args == null) ? 0 : args.length;
		if (len == 0) {
			args = CachedPrimitive.NO_PARAM_CLASS;
		} else {
			Class<?> pc;
			pms = new boolean[len];
			for (int i = 0; i < len; i++) {
				pms[i] = args[i].isPrimitive();
				pc = CachedPrimitive.CONV_PRIMITIVE.get(args[i]);
				if (pc != null) {
					args[i] = pc;
				}
			}
		}
		if (!method.isAccessible())
			method.setAccessible(true);
		this.method = method;
		this.params = args;
		this.primitives = pms;
		this.paramsLength = len;
		this.isStatic = Modifier.isStatic(method.getModifiers());
	}
}
